package com.ruoyi.web.controller.jwtTest;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;

import java.util.Map;

public class Test01 {
    public static void main(String[] args) {
        // 令牌自定义标识
        String header = "Authorization";

        // 令牌秘钥
        String secret = "abcdefghijklmnopqrstuvwxyz";

        String token = "eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE2NDY2NDQwMTMsImxvZ2luX3VzZXJfa2V5Ijp7InNlYXJjaFZhbHVlIjpudWxsLCJjcmVhdGVCeSI6bnVsbCwiY3JlYXRlVGltZSI6bnVsbCwidXBkYXRlQnkiOm51bGwsInVwZGF0ZVRpbWUiOm51bGwsInJlbWFyayI6bnVsbCwicGFyYW1zIjp7fSwiaWQiOm51bGwsIm5hbWUiOiLlvKDkuIkiLCJwaG9uZW51bWJlciI6IjE1MzQzNDU1NjIzIiwic2V4IjpudWxsLCJwYXNzd29yZCI6bnVsbCwiZW5jcnlwdGVkdG9rZW4iOm51bGx9fQ.u8NKiDdTMye5VgMRgfTRJp12hZE9vYW1y91ujJ8ka_tTSg1Kl-JZOuaVW1I_cuNoBCi6HxIV8iHoVqhOJ76Ngg";

        Jws<Claims> claimsJws = Jwts.parser().setSigningKey(secret).parseClaimsJws(token);
        Claims claims = claimsJws.getBody();
        Map<String,Object> map = (Map<String, Object>) claims.get("login_user_key");
        for(String key:map.keySet()){
            System.out.println("key:"+key+" "+"Value:"+map.get(key));
        }
        System.out.println("------------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        System.out.println(map.get("name"));
    }
}
